/**
 *
 */
package com.gitee.lougnib.simple.mybatis.generator.plugin;

import java.util.List;

import org.mybatis.generator.api.IntrospectedTable;
import org.mybatis.generator.api.PluginAdapter;

/**
 * 重命名 Mapper 为 Dao 的插件。
 *
 * @author lougnib@163.com
 * @since 2021/07/16
 * @version 2021/07/16
 */
public class RenameMapperToDaoPlugin extends PluginAdapter {

	@Override
	public void initialized(IntrospectedTable introspectedTable) {
		super.initialized(introspectedTable);

		String type = introspectedTable.getMyBatis3JavaMapperType();
		introspectedTable.setMyBatis3JavaMapperType(type.replaceAll("Mapper$", "Dao"));

		String xml = introspectedTable.getMyBatis3XmlMapperFileName();
		introspectedTable.setMyBatis3XmlMapperFileName(xml.replaceAll("Mapper\\.xml$", "Dao.xml"));
	}

	@Override
	public boolean validate(List<String> warnings) {
		return true;
	}

}
